Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

247
Views
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined and code: 'ERR_INVALID_ARG_TYPE'
import dotenv from "dotenv";
import path from 'path';

dotenv.config({
  path: path.resolve(path.__dirname, `${process.env.NODE_ENV}.env`),
});

export default config = {
  NODE_ENV: process.env.NODE_ENV || "development",
  HOST: process.env.HOST || "localhost",
  PORT: process.env.PORT || 3001,
};

When i try to make config.js file to work multiple .env files but i get this error.os : windows 10

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

__dirname is not located in the path module so path.__dirname is undefined.

You should use __dirname.

See here : https://www.digitalocean.com/community/tutorials/nodejs-how-to-use__dirname#:~:text=__dirname%20is%20an%20environment,js%20project.

about 4 years ago · Juan Pablo Isaza Report

0

i solved with that:

import dotenv from "dotenv";
import path from 'path';

dotenv.config({
  path: path.resolve(path.dirname("/"), `${process.env.NODE_ENV}.env`),
});
const config = {
  NODE_ENV: process.env.NODE_ENV || "development",
  HOST: process.env.HOST || "localhost",
  PORT: process.env.PORT || 3001,
};


export default config;
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!